{To compile NIH Image so that it supports Scion PCI frame grabbers you
will need to set 'SupportScionPCI' to 1 and add the following libraries
in the NIH Image project:
ScionPCI.lib
PCILib
NameRegistryLib
DriverServicesLib
ScionPCI.lib is included with the NIH Image source. The other libraries
are on Apple's Developer CD.}
{$SETC SupportScionPCI := 1}
{$ifc PowerPC and SupportScionPCI}
function LookForPCIFrameGrabbers(model: integer; var base0: longint; var base1: longint; var buffers: longint): boolean; C; EXTERNAL;
{$endc}
implementation
procedure MakeCursors;
var
TempCurH: CursHandle;
i, id: integer;
begin
TempCurH := GetCursor(PickerCursorID);
if TempCurH <> nil then
begin
PickerCursor := TempCurH^^;
ToolCursor[PickerTool] := PickerCursor;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(CrossCursorPlusID);
if TempCurH <> nil then
begin
CrossPlusCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(CrossCursorMinusID);
if TempCurH <> nil then
begin
CrossMinusCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(WandPlusCursorID);
if TempCurH <> nil then
begin
WandPlusCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(WandMinusCursorID);
if TempCurH <> nil then
begin
WandMinusCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(CrossCursorID);
if TempCurH <> nil then
begin
ToolCursor[SelectionTool] := TempCurH^^;
ToolCursor[FreehandTool] := TempCurH^^;
ToolCursor[PolygonTool] := TempCurH^^;
ToolCursor[ruler] := TempCurH^^;
ToolCursor[PlotTool] := TempCurH^^;
ToolCursor[OvalSelectionTool] := TempCurH^^;
ToolCursor[LineTool] := TempCurH^^;
ToolCursor[AngleTool] := TempCurH^^;
ToolCursor[CrossHairTool] := TempCurH^^;
ToolCursor[LUTTool] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(LUTCursorID);
if TempCurH <> nil then
begin
LUTCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(gmCursorID);
if TempCurH <> nil then
begin
gmCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(GrabberCursorID);
if TempCurH <> nil then
begin
ToolCursor[Grabber] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(PencilCursorID);
if TempCurH <> nil then
begin
ToolCursor[Pencil] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(GlassCursorPlusID);
if TempCurH <> nil then
begin
ToolCursor[MagnifyingGlass] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(GlassCursorMinusID);
if TempCurH <> nil then
begin
GlassMinusCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(BucketCursorID);
if TempCurH <> nil then
begin
ToolCursor[PaintBucket] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(WandCursorID);
if TempCurH <> nil then
begin
ToolCursor[Wand] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(TextCursorID);
if TempCurH <> nil then
begin
ToolCursor[TextTool] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(EraserCursorID);
if TempCurH <> nil then
begin
ToolCursor[eraser] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(SprayCursorID);
if TempCurH <> nil then
begin
ToolCursor[SprayCanTool] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(BrushCursorID);
if TempCurH <> nil then
begin
ToolCursor[brush] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
TempCurH := GetCursor(WatchCursor);
if TempCurH <> nil then
begin
watch := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
for i := 1 to 8 do
AnimatedWatch[i] := watch;
id := FirstAnimatedWatchID;
for i := 2 to 8 do
begin
TempCurH := GetCursor(id);
id := id + 1;
if TempCurH <> nil then
begin
AnimatedWatch[i] := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
end;
TempCurH := GetCursor(FingerCursorID);
if TempCurH <> nil then
begin
FingerCursor := TempCurH^^;
ReleaseResource(handle(TempCurH));
end;
end;
procedure MakeToolsBitMap;
{Creates the offscreen bitmap used to draw the tool palette.}
var
tPort: GrafPtr;
TempPort: GrafPort;
PicH: PicHandle;
FrameRect: rect;
fwidth, fheight: integer;
begin
PicH := GetPicture(130);
if PicH = nil then
ExitToShell;
FrameRect := PicH^^.PicFrame;
with FrameRect do
begin
fwidth := right - left;
fheight := bottom - top;
end;
GetPort(tPort);
OpenPort(@TempPort);
with ToolBits, FrameRect do
begin
baseAddr := NewPtr((fwidth * fheight) div 8);
if baseAddr = nil then
ExitToShell;
rowBytes := fwidth div 8;
SetRect(bounds, 0, 0, fwidth, fheight);
end;
SetPortBits(ToolBits);
DrawPicture(PicH, ToolBits.bounds);
ReleaseResource(handle(PicH));
ClosePort(@TempPort);
SetPort(tPort);
end;
procedure InitTools;
var
ToolTop, LinesTop, i: integer;
Tool: ToolType;
begin
MakeToolsBitmap;
FirstTool := MagnifyingGlass;
LastTool := CrossHairTool;
CurrentTool := SelectionTool;
isSelectionTool := true;
PreviousTool := CurrentTool;
ToolTop := 0;
for tool := FirstTool to LastTool do
with ToolRect[tool] do
begin
top := ToolTop;
bottom := top + tmiddle;
if odd(ord(tool) + 1) then
left := 0
else
begin
left := tmiddle;
ToolTop := ToolTop + tmiddle;
end;
right := left + tmiddle;
end;
ToolTime := 0;
LutTime := 0;
StartOfLines := ToolRect[LastTool].bottom - 1;
LinesTop := StartOfLines + 10;
for i := 1 to nLineTypes do
with lines[i] do
begin
left := LinesLeft;
top := LinesTop;
right := LinesRight;
case i of
1, 2, 3, 4:
bottom := top + i;
5:
bottom := top + 6;
6:
bottom := top + 8
end;
LinesTop := bottom + 4;
end;
LineWidth := 1;
LineIndex := 1;
with CheckRect do
begin
left := 0;
top := StartOfLines;
right := LinesLeft;
bottom := theight;
end;
end;
procedure AllocateBuffers;
var
tPort: GrafPtr;
err: OSErr;
BufSizeStr: str255;
atemp: integer;
SaveGDevice: GDHandle;
begin
SaveGDevice := GetGDevice;
SetGDevice(osGDevice);
GetPort(tPort);
NumToString(BufferSize div 1024, BufSizeStr);
BigBufSize := BufferSize * 2;
if FreeMem > (BigBufSize + 300000) then
BigBuf := NewPtr(BigBufSize)
else
BigBuf := nil;
if BigBuf = nil then
BigBufSize := 0;
if BigBuf <> nil then
UndoBuf := BigBuf
else
begin
if FreeMem > (BufferSize + 200000) then
UndoBuf := NewPtr(BufferSize)
else
UndoBuf := nil;
end;
if UndoBuf <> nil then
UndoBufSize := BufferSize
else
begin
PutError(concat('There is not enough memory available to allocate the ', BufSizeStr, 'K Undo buffer. Many operations may fail or may not be Undoable.'));
PutError(concat('There is not enough memory available to allocate the ', BufSizeStr, 'K Clipboard Buffer. Many operations, including Copy and Paste, may fail.'));
ClipBufSize := 0;
end;
SetPort(tPort);
SetGDevice(SaveGDevice);
end;
procedure AllocateArrays;
var
nItems: LongInt;
i: integer;
procedure Abort;
begin
PutError('Not enough memory available to allocate arrays.');